import { http } from "@/utils/http"

export interface userVO {
  id: number;
  uid: string;
  uname: string;
  email: string;
  phone: string;
  sex: string;
  birthday: Date | string;
  avatarUrl: string;
  description: string;
  isSinger: number;
}

export const userManageAPI = () => {
  const getUserByName = (name:string, page:number, rows:number): any => {
    return http.get(`user/page?key=${name}&page=${page}&rows=${rows}`);
  };
  
  const addUser = (data: userVO): any => {
    return http.post("user/adduser", data);
  };
  
  const updateUser = (data: userVO): any => {
    return http.post("user/updateUserInfo", data);
  };
  
  const deleteUser = (id: number): any => {
    // 修改为直接传递uid参数，而不是对象
    return http.post(`user/deleteUser?id=${id}`);
  };

  return {
    getUserByName,
    addUser,
    updateUser,
    deleteUser
  };
}